import IPairTxData from '~/models/IData'
import IPlugin from './IPlugin'
import wldata from '~/config/whitelist.json'
const whitelist = wldata.whitelist.map(item => item.toLowerCase())

export default class WhiteListPlugin implements IPlugin {

    name = 'WhiteList'

    async modData(data: IPairTxData) {
        const mints = data.mints
        const burns = data.burns
        const swaps = data.swaps

        for (let i = 0; i < mints.length; i++) {
            mints[i].outerAccount = !whitelist.includes(mints[i].account as string)
        }
        for (let i = 0; i < burns.length; i++) {
            burns[i].outerAccount = !whitelist.includes(burns[i].account as string)
        }
        for (let i = 0; i < swaps.length; i++) {
            swaps[i].outerAccount = !whitelist.includes(swaps[i].account as string)
        }
        return data
    }
}
